package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Position;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PositionDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "岗位名称")
    private String name;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "状态：0禁用1启用")
    private Integer state;

    @ApiModelProperty(value = "管理岗：1、直接主管，2普通员工,3、其他管理类岗位")
    private Integer managementState;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "岗位备注")
    private String remark;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;


    public PositionDTO() {}

    public PositionDTO(Position entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static PositionDTO convert(Position entity) {
        return new PositionDTO(entity);
    }

    public static List<PositionDTO> convertList(List<Position> list) {
        List<PositionDTO> resultList = new ArrayList<>();
        for (Position entity : list) {
            resultList.add(new PositionDTO(entity));
        }
        return resultList;
    }}
